﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;

namespace TextMIS
{
    public partial class frmDoctorRegis : Form
    {
        public frmDoctorRegis()
        {
            InitializeComponent();
        }

        SqlConnection conn;
 //       SqlDataAdapter da;
        SqlCommand com;

        private void frmDoctorRegis_Load(object sender, EventArgs e)
        {
            conn = new SqlConnection(frmLogin.SQLstr);
        }

        private void btnRepeat_Click(object sender, EventArgs e)
        {
            txtUserName.Clear();
            txtUserPwd.Clear();
            txtSecondPwd.Clear();

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtUserPwd.Text == txtSecondPwd.Text)
            {
                com = new SqlCommand("insert into UserInfo(UserName,UserPassword,UserRight)values('" + txtUserName.Text.Trim() +
    "','" + txtUserPwd.Text.Trim() + "','体检医生')", conn);

                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                com.ExecuteNonQuery();
                conn.Close();

                MessageBox.Show("恭喜你！注册成功！");
                com = new SqlCommand("insert into DoctorInfo(Username)values('" + txtUserName.Text.Trim() + "')", conn);



                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                com.ExecuteNonQuery();
                conn.Close();

            }
            else
            { MessageBox.Show("两次输入密码有误!"); }
        }

        private void btnReturn_Click(object sender, EventArgs e)
        {
            this.Close();
        }



    }
}
